package com.dangf.app.launcher.dao

import com.alibaba.fastjson.JSON
import com.dangf.app.launcher.app.V
import com.dangf.app.launcher.entity.Machine
import com.dangf.app.launcher.model.AdvertModel
import com.dangf.app.launcher.model.MachineModel
import com.dangf.app.launcher.model.SoftModel
import com.dangf.app.launcher.model.StoreModel
import pw.hais.utils_lib.http.Http
import pw.hais.utils_lib.http.OnHttpListener
import java.net.URLEncoder


/**
 * 主要的数据接口
 * Created by hais1992 on 2017/9/6/006.
 */
object MainDao {
    //
    fun getStoreInfo(listener: OnHttpListener<StoreModel>) {
        Http.get(1, V.URL_GET_STORE, mapOf(), listener)
    }

    //根据唯一码 获取机器信息
    fun getMachineInfo(code: String, listener: OnHttpListener<MachineModel>) {
        val params = mutableMapOf<String, Any>()
        params.put("code", code)
        Http.get(2, V.URL_GET_MACHINE, params, listener)
    }

    //注册机器
    fun registerMachineInfo(machine: Machine, listener: OnHttpListener<MachineModel>) {
        val params = mutableMapOf<String, Any>()
        params.put("machine", URLEncoder.encode(JSON.toJSONString(machine), "utf-8"))
        Http.get(3, V.URL_REGISTER_MACHINE, params, listener)
    }


    //获取应用列表
    fun getAppList(code: String, listener: OnHttpListener<SoftModel>) {
        val params = mutableMapOf<String, Any>()
        params.put("code", code)
        Http.get(4, V.URL_GET_SOFTS, params, listener)

//        val apps = arrayListOf<Soft>()
//        apps.add(Soft("com.tencent.tmgp.sgame", "王者荣耀", "http://dlied5.myapp.com/myapp/1104466820/sgame/2017_com.tencent.tmgp.sgame_h100_1.22.1.5.apk", "", "http://image.coolapk.com/apk_logo/2017/0605/0_1496637436_9062.png.t.png", "1.22.1.5", "首次上架", 0, false))
//        apps.add(Soft("com.tencent.tmgp.cf", "穿越火线", "https://dlied5.myapp.com/myapp/1104512706/cf/2017_com.tencent.tmgp.cf_h100_1.0.22.160.apk", "", "http://image.coolapk.com/apk_logo/2015/1205/12202_1449287315_1491.jpg", "1.0.22.160", "首次上架", 0, false))
//        apps.add(Soft("com.tencent.feiji", "全民飞机大战", "http://imtt.dd.qq.com/16891/7F4253646B6DA490B71A773DDBBF6371.apk", "", "http://shp.qpic.cn/ma_icon/0/icon_10366241_1502934487/256", "1.0.63", "首次上架", 0, false))
//        apps.add(Soft("com.netease.onmyoji", "阴阳师", "https://g37.gdl.netease.com/onmyoji_netease_14_1.0.28.apk", "", "http://image.coolapk.com/apk_logo/2017/0315/605b649311ee9f94d8b5bc7fa8b0a297-for-79179-o_1bb8qld3ccefh2o1hudm6cjq1q-uid-12202.png", "1.0.26", "首次上架", 0, false))
//        apps.add(Soft("com.tencent.pao", "天天酷跑", "http://imtt.dd.qq.com/16891/506858DC948DF05C0220656025518A77.apk", "", "http://shp.qpic.cn/ma_icon/0/icon_10099632_1503285919/256", "1.0.48.0", "首次上架", 0, false))
//
//        apps.add(Soft("com.tencent.tmgp.ddtank", "弹弹堂", "http://dlied5.myapp.com/myapp/1105192975/1105192975/ddtank/10006654_com.tencent.tmgp.ddtank_u109_1.7.10.apk", "", "http://image.coolapk.com/apk_logo/2017/0426/png-for-137033-o_1beiup4o1sus1m0b1je914losodq-uid-12202.png", "1.7.10", "首次上架", 0, false))
//        apps.add(Soft("com.qqgame.hlddz", "欢乐斗地主", "http://imtt.dd.qq.com/16891/694AE157B4B59E158F319B5CD67B4FF8.apk", "", "http://shp.qpic.cn/ma_icon/0/icon_97949_1504078686/256", "5.72.002", "首次上架", 0, false))
//        apps.add(Soft("com.tencent.peng", "天天爱消除", "http://shouji.360tpcdn.com/170920/feb5a1399fdb1d1ac89f8cc6e5534430/com.tencent.peng_70.apk", "", "http://image.coolapk.com/apk_logo/2013/0805/12202_1375696957_3902.png", "1.51.0.0Build261", "首次上架", 0, false))
//        apps.add(Soft("com.qqgame.mic", "英雄杀", "http://imtt.dd.qq.com/16891/44564EC409EA864D41153D1E5A60BBCC.apk", "", "http://shp.qpic.cn/ma_icon/0/icon_1105393_1503993214/256", "3.16.1", "首次上架", 0, false))
//        apps.add(Soft("com.tencent.KiHan", "火影忍者", "http://shouji.360tpcdn.com/170913/afc1a5cd8165ac12e19c27180640aff4/com.tencent.KiHan_1020013003.apk", "", "http://p3.qhimg.com/t017a5b40af0533977c.png", "2.0.2.0", "首次上架", 0, false))
//
//        apps.add(Soft("com.activision.callofduty.striketeam", "使命召唤", "http://down.muzhiwan.com/2017/05/23/com.activision.callofduty.striketeam5923ff46ea14e.gpk", "", "http://img01.muzhiwan.com/screen/000/09/26/40/icons.png", "1.0.40", "首次上架", 0, false))
//        apps.add(Soft("com.gameloft.android.ANMP.GloftGGHM", "孤胆车神", "http://hzdown.muzhiwan.com/2017/08/25/com.gameloft.android.ANMP.GloftGGHM599faba8a3976.gpk", "", "http://img01.muzhiwan.com/2017/08/25/com.gameloft.android.ANMP.GloftGGHM_142285/599fa3621c5c6.png", "3.3.0", "首次上架", 0, false))
//        apps.add(Soft("com.gameloft.android.ANMP.GloftM5HM", "现代战争", "http://hzdown.muzhiwan.com/2017/07/27/com.gameloft.android.ANMP.GloftM5HM597970b73379a.gpk", "", "http://img02.muzhiwan.com/2017/02/22/com.gameloft.android.ANMP.GloftM5HM_134566/58ad6002dd850.png", "3.3.0", "首次上架", 0, false))
//        apps.add(Soft("com.gameloft.android.ANMP.GloftA8HM", "狂野飙车", "http://hzdown.muzhiwan.com/2017/09/08/com.gameloft.android.ANMP.GloftA8HM59b2141c40dc0.gpk", "", "http://img01.muzhiwan.com/2017/09/08/com.gameloft.android.ANMP.GloftA8HM_142877/59b210a4550e6.png", "3.3.0", "首次上架", 0, false))
//        apps.add(Soft("com.atypicalgames.radiationisland", "辐射岛", "http://hzdown.muzhiwan.com/2017/04/28/com.atypicalgames.radiationisland5902ba548421a.gpk", "", "http://img01.muzhiwan.com/2017/02/15/com.atypicalgames.radiationisland_134319/58a4359dd839e.png", "3.3.0", "首次上架", 0, false))
//
//        apps.add(Soft("com.ss.android.article.lite", "今日头条", "http://m.shouji.360tpcdn.com/170921/8a7bcfce83286547342adc062f1225d1/com.ss.android.article.lite_610.apk", "", "http://shp.qpic.cn/ma_icon/0/icon_42392809_1504769084/256", "6.0.8", "首次上架", 0, false))
//        apps.add(Soft("mark.via", "Via浏览器", "http://shouji.360tpcdn.com/170810/0aaa759e1d2bef5d0c64ed366dfa510b/mark.via_20170810.apk", "", "http://image.coolapk.com/apk_logo/2017/0212/via_big_logo_512-for-14736-o_1b8ol364v1r4kqk42epu8tmcnq-uid-441319.png", "3.2.0", "首次上架", 0, false))
//        apps.add(Soft("hanjie.app.pureweather", "天气预报", "http://dl-cdn.coolapkmarket.com/down/apk_upload/2017/0725/PureWeather_v_6_0_5-for-21838-o_1blt28os71lauer013thsoi1m2dq-uid-513767.apk", "", "http://image.coolapk.com/apk_logo/2016/0802/new_logo-for-21838-o_1ap5hkt151350dcj1d12aov1tq510-uid-513767.png", "6.0.5", "首次上架", 0, false))
//        apps.add(Soft("com.tencent.mobileqq", "手机QQ", "https://www.apkmirror.com/wp-content/uploads/uploaded/59967f6a14b2a/com.tencent.mobileqq_7.1.8-718_minAPI15(armeabi)(nodpi)_apkmirror.com.apk", "", "http://shp.qpic.cn/ma_icon/0/icon_10325815_1503024973/256", "3.6.0", "首次上架", 0, false))
//        apps.add(Soft("com.zhongduomei.rrmj.society", "人人视频", "http://imtt.dd.qq.com/16891/3D6CE98B3C16CD113C738B8E986FD7E0.apk", "", "http://shp.qpic.cn/ma_icon/0/icon_12071376_1505453061/256", "3.6.2.1", "首次上架", 0, false))
//
//        apps.add(Soft("com.dangf.app.suoping", "挂机锁屏", "", "", R.drawable.icon_guajisuo, "1", "首次上架", 0, false))
//        apps.add(Soft("com.dangf.app.diancan", "在线点餐", "", "", R.drawable.icon_diancan, "1", "首次上架", 0, false))
//        apps.add(Soft("com.dangf.app.clean", "清理数据", "", "", R.drawable.icon_qingli, "1", "首次上架", 0, false))
//        apps.add(Soft("com.dangf.app.setting", "设备调节", "", "", R.drawable.icon_seeting_shezhi, "1", "首次上架", 0, false))
//        apps.add(Soft("com.dangf.app.jiaoben", "游戏脚本", "", "", R.drawable.icon_jiaoben, "1", "首次上架", 0, false))
//
//        apps.add(Soft("com.coolapk.market", "酷安", "http://shouji.360tpcdn.com/170630/5dddb9a16f4ae4175b0aad5dddc97519/com.coolapk.market_1706301.apk", "", "http://image.coolapk.com/apk_logo/2016/0108/12202_1452248424_4592.png", "6.0.5", "首次上架", 0, true))
//        apps.add(Soft("com.android.settings", "系统设置", "", "", R.drawable.icon_system_shezhi, "1", "首次上架", 0, true))

//        listener.onSuccess(0, null, BaseArrayModel(100, "", apps))
    }

    //获取公告最新的
    fun getAdvertLast(code: String, listener: OnHttpListener<AdvertModel>) {
        val params = mutableMapOf<String, Any>()
        params.put("code", code)
        Http.get(5, V.URL_GET_ADVERT_LAST, params, listener)
    }

}